<?php
/**
 * Created By PhpStorm
 * Author: patrick wu
 * Date: 2020/10/7
 * Time: 16:22
 */
namespace App\Http\Model\Mysql;

use Illuminate\Database\Eloquent\Model;

class UserModel extends Model
{
    protected $table    =   'mini_user';

    protected $guarded  =   [];

    protected $dateFormat   =   'U';

    protected $primaryKey   =   'uid';

    /**
     * 定义连接用户地址表
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function address()
    {
        return $this->hasMany(UserAddressModel::class, 'user_id', 'uid');
    }

    /**
     * 定义连接用户绑定表
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function bind()
    {
        return $this->hasOne(UserBindModel::class, 'bind_user', 'uid');
    }

    /**
     * 定义连接用户分享表
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function share()
    {
        return $this->hasMany(UserBindModel::class, 'share', 'uid');
    }
}
